package org.ipower.examsystem.service.impl;

import java.util.List;
import org.ipower.examsystem.dao.CooperationDao;
import org.ipower.examsystem.domain.Cooperation;
import org.ipower.examsystem.service.CooperationService;
import org.ipower.platform.domain.Pager;
import org.ipower.platform.domain.QueryCondition;

/**
 *合作机构服务现实类。
 *@author jeasonyoung
 */
public class CooperationServiceImpl implements CooperationService {
    private static final long serialVersionUID = 1L;
    private CooperationDao dao = null;
    
    @Override
    public void setCooperationDao(CooperationDao dao) {
       this.dao = dao;
    }
   
    @Override
    public Pager<Cooperation> findAll(String ascProperty, boolean isAsc, int start, int limit, List<QueryCondition> entites) {
        return this.dao.findAll(ascProperty, isAsc, start, limit, entites);
    }

    @Override
    public void saveOrUpdate(Cooperation data) {
        if(data != null && data.getCooperationID() != null && !data.getCooperationID().isEmpty()){
            if(this.dao.load(data.getCooperationID()) == null){
                this.dao.save(data);
            }else{
                this.dao.update(data);
            }
        }
    }

    @Override
    public void delete(String cooperationID) {
        if(cooperationID != null && !cooperationID.isEmpty()){
            this.dao.delete(cooperationID);
        }
    }
}